//
//  DriverAuthenticationController.m
//  NtoccDriverNew
//
//  Created by 张天兴 on 2025/9/16.
//  Copyright © 2025 GCY. All rights reserved.
//

#import "DriverAuthenticationController.h"
#import "AutherTicationCellTableViewCell.h"
#import "IDCardTitleTextTableViewCell.h"
#import "TZImagePickerController.h"
#import "SelectedImagUpDataImagView.h"
#import "CarAuthenticationController.h"
#import "AuthentErrorTitleCell.h"

@interface DriverAuthenticationController ()<UITableViewDelegate, UITableViewDataSource,TZImagePickerControllerDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate>
@property (strong , nonatomic)UITableView *tableView;
@property (nonatomic, strong) UIImagePickerController *imagePickerController;
@property (strong, nonatomic)SelectedImagUpDataImagView *selectedTypeView;
@property (strong, nonatomic) NSMutableArray *dataArr;
@property (strong, nonatomic) NSIndexPath *curentIndexPath;
@property (strong,nonatomic) UIButton *commitUpDataButton;
@property (assign,nonatomic) BOOL daoluUpTimeBool;//道路运输从业资格证过期提示是否隐藏
@property (nonatomic, strong) NSMutableDictionary *jszDic;
@property (nonatomic, strong) NSMutableDictionary *jszFyDic;
@property (nonatomic, strong) NSMutableDictionary *cyzgzDic;
@property (nonatomic, strong) NSMutableDictionary *cyzgzDicTime;

@end

@implementation DriverAuthenticationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"司机认证";
    
    self.view.backgroundColor = BackgroundColor;
    [self newDataArr];
    [self setupNav];
    self.jszDic = [NSMutableDictionary dictionary];
    self.jszFyDic = [NSMutableDictionary dictionary];
    self.cyzgzDic =  [NSMutableDictionary dictionary];
    self.cyzgzDicTime =  [NSMutableDictionary dictionary];
    [self.view addSubview:self.tableView];
    [self.view addSubview:self.commitUpDataButton];
    self.daoluUpTimeBool = YES;
}
- (void)newDataArr{
    self.dataArr = [@[] mutableCopy];
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setValue:@"机动车驾驶证" forKey:@"title"];
    [dic setValue:@"jiashizhengzheng" forKey:@"defaultImag"];
    [dic setValue:@"" forKey:@"imgURL"];
    [dic setValue:@"0" forKey:@"upType"];
    [dic setValue:@"识别失败(点击重新上传)" forKey:@"falseTitle"];
    [dic setValue:@"曝光严重无法准确识别文字内容" forKey:@"falseCentent"];
    [dic setValue:@"jiashizhengzhengm" forKey:@"ballbackImag"];

    [self.dataArr addObject:dic];
    NSMutableDictionary *dic1 = [NSMutableDictionary dictionary];
    [dic1 setValue:@"道路运输从业资格证" forKey:@"title"];
    [dic1 setValue:@"" forKey:@"imgURL"];
    [dic1 setValue:@"0" forKey:@"upType"];//0没识别之前 1 成功。2 失败
    [dic1 setValue:@"识别失败(点击重新上传)" forKey:@"falseTitle"];
    [dic1 setValue:@"曝光严重无法准确识别文字内容" forKey:@"falseCentent"];
    [dic1 setValue:@"daolucongyezigezheng" forKey:@"defaultImag"];
    [dic1 setValue:@"congyezigezhengshilie" forKey:@"ballbackImag"];
    [self.dataArr addObject:dic1];
}
#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 1) {
        return 258;
    }else{
        return 145;
       
    }
   
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.001f;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        AuthentErrorTitleCell *cell =[tableView dequeueReusableCellWithIdentifier:@"AuthentErrorTitleCell"];
        cell.cententLabel.text = self.authMsgStr;
        return cell;
    }else if (indexPath.section == 1) {
        AutherTicationCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AutherTicationCellTableViewCell"];
        [cell.upImagButton addTarget:self action:@selector(updataImage:) forControlEvents:(UIControlEventTouchUpInside)];
        [cell.topBakButton addTarget:self action:@selector(updataImage:) forControlEvents:(UIControlEventTouchUpInside)];
        [cell assignmentDic:self.dataArr[indexPath.row]];
        return cell;
    }else{
        IDCardTitleTextTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IDCardTitleTextTableViewCell"];
        return cell;
    }

}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 1) {
        return self.dataArr.count;
    }else{
        if ([DCSpeedy isBlankString:self.authMsgStr] || self.authMsgStr.length <= 0) {
            return 0;
        }else{
            return 1;
        }
        
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    if (self.daoluUpTimeBool == NO) {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, 100)];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, ScreenW - 30, 80)];
        label.text = @"提示：您上传的道路运输从业资格证过期了，继续提交会影响您后续正常接单功能！如果您上传的证件未过期，请直接点击下一步或上传审核，将会由人工审核帮您审核。";
        label.textColor = [UIColor colorWithRed:237/255.0 green:107/255.0 blue:134/255.0 alpha:1];
        label.font = [UIFont systemFontOfSize:14];
        label.numberOfLines = 0;
        [view addSubview:label];
        return view;
    }else{
        UIView *view = [[UIView alloc] init];
        return view;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (self.daoluUpTimeBool == NO) {
        return 80;
    }else{
        return 0.00001;
    }
   
}
#pragma mark - LazyLoad
- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.frame = CGRectMake(0, 0, ScreenW, ScreenH - NavHeight - MenuBarHeight  - 50);
        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.bounds.size.width, 0.01f)];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.backgroundColor = BackgroundColor;
        
        //注册单元格
        [_tableView registerNib:[UINib nibWithNibName:@"AuthentErrorTitleCell" bundle:nil] forCellReuseIdentifier:@"AuthentErrorTitleCell"];
        [_tableView registerNib:[UINib nibWithNibName:@"AutherTicationCellTableViewCell" bundle:nil] forCellReuseIdentifier:@"AutherTicationCellTableViewCell"];
        [_tableView registerNib:[UINib nibWithNibName:@"IDCardTitleTextTableViewCell" bundle:nil] forCellReuseIdentifier:@"IDCardTitleTextTableViewCell"];
    }
    
    return _tableView;
}

- (UIButton *)commitUpDataButton{
    if (_commitUpDataButton == nil) {
        self.commitUpDataButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.commitUpDataButton.frame = CGRectMake(15, ScreenH - MenuBarHeight - 50 - NavHeight, ScreenW - 30, 50);
        [self.commitUpDataButton addTarget:self action:@selector(commitUpDataButtonAction) forControlEvents:UIControlEventTouchUpInside];
        self.commitUpDataButton.backgroundColor = Theme_ColorValue;
        [self.commitUpDataButton setTitle:@"确认上传" forState:(UIControlStateNormal)];
        [self.commitUpDataButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        self.commitUpDataButton.layer.masksToBounds = YES;
        self.commitUpDataButton.layer.cornerRadius = 10;
    }
    return _commitUpDataButton;
}
- (void)commitUpDataButtonAction{

    NSString * driverLicenseOCR = [self dicZhuanJsonStr:self.jszDic];
    NSString *driverLicenseOCRBackStr  = [self dicZhuanJsonStr:self.jszFyDic];
    NSString * roadTransportProfessionalOCRStr = [self dicZhuanJsonStr:self.cyzgzDic];
    NSString * newRoadTransportProfessionalOCR = [self dicZhuanJsonStr:self.cyzgzDicTime];
    NSString *driverLicenseImg;
    NSString *driverLicenseBackImg;
    NSString *workLicenseImg;
    NSString *newWorkLicenseImg;
    for (NSDictionary *dict in self.dataArr) {
        if ([dict[@"title"] isEqualToString:@"机动车驾驶证"]) {
            driverLicenseImg = dict[@"imgURL"];
        }else if ([dict[@"title"] isEqualToString:@"电子机动车驾驶证副页上传"]){
            driverLicenseBackImg = dict[@"imgURL"];
        }else if ([dict[@"title"] isEqualToString:@"道路运输从业资格证"]){
            workLicenseImg = dict[@"imgURL"];
        }else if ([dict[@"title"] isEqualToString:@"道路运输从业资格证有效期最新页(没有就不上传)"]){
            newWorkLicenseImg = dict[@"imgURL"];
        }
    }
    if (driverLicenseImg.length <= 0 || driverLicenseOCR.length <= 0) {
        [XSInfoView showInfo:@"请正确上传机动车驾驶证" onView:self.view];
        return;
    }
    if (workLicenseImg.length <= 0 ||  roadTransportProfessionalOCRStr.length <= 0) {
        [XSInfoView showInfo:@"请正确上传道路运输从业资格证" onView:self.view];
        return;
    }
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setValue:driverLicenseOCR forKey:@"driverLicenseOCRStr"];
    [dic setValue:driverLicenseOCRBackStr forKey:@"driverLicenseOCRBackStr"];
    [dic setValue:roadTransportProfessionalOCRStr forKey:@"roadTransportProfessionalOCRStr"];
    [dic setValue:newRoadTransportProfessionalOCR forKey:@"newRoadTransportProfessionalOCRStr"];
    [dic setValue:driverLicenseImg forKey:@"driverLicenseImg"];
    [dic setValue:driverLicenseBackImg forKey:@"driverLicenseBackImg"];
    [dic setValue:workLicenseImg forKey:@"workLicenseImg"];
    [dic setValue:newWorkLicenseImg forKey:@"newWorkLicenseImg"];
    [HTTPManager jsonNetworkRequestWithMethod:@"POST" urlString:CJStringWithFormat(@"%@%@", [NSString stringWithFormat:@"%@/ntocc-basic-api",[ReAddressDynamic shared].baseUrl], DriverOcrUpdateInfo) withParameter:dic withVC:self netName:@"司机认证" success:^(id response, NSString *msg) {
        if ([self.sussType isEqualToString:@"0"]) {
            CarAuthenticationController *VC = [[CarAuthenticationController alloc] init];
            VC.sussType = self.sussType;
            [self.navigationController pushViewController:VC animated:YES];
        }else{
            [self.navigationController popToRootViewControllerAnimated:YES];
        }
        } failure:^(NSInteger code, NSString *msg) {
            
        }];

}
- (void)updataImage:(UIButton *)btn{
    WEAKSELF
    CGPoint point = btn.center;//找到btn中心点记录下来
    point = [self.tableView convertPoint:point fromView:btn.superview];
    NSIndexPath* indexpath = [self.tableView indexPathForRowAtPoint:point];
    self.curentIndexPath = indexpath;
    NSDictionary *dict = self.dataArr[indexpath.row];
    self.selectedTypeView = [[SelectedImagUpDataImagView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH)ImgStr:dict[@"ballbackImag"]];
    self.selectedTypeView.selectedType = ^(NSString * _Nonnull isTakeAPhoto) {
        if ([isTakeAPhoto isEqualToString:@"1"]) {
//            NSLog(@"拍照");
            [weakSelf checkCameraPermission];
        }else if ([isTakeAPhoto isEqualToString:@"2"]){
//            NSLog(@"相册");
            [weakSelf pushPhotoViewEvent];
           
        }else{
            NSLog(@"取消");
        }
        [weakSelf.selectedTypeView removeFromSuperview];
    };
    [[UIApplication sharedApplication].keyWindow addSubview:self.selectedTypeView];
}
- (void)pushPhotoViewEvent {
    
    [SystemPermissionsToolObject determineLatestPermissionsOfTheLocalAlbum];
    
    TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 columnNumber:4 delegate:self pushPhotoPickerVc:YES];
    imagePickerVc.allowPickingVideo = NO;
    [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
        
        NSArray *imgArr = [NSArray array];
        
        imgArr = photos;
        
        NSString *uploadUrl = CJStringWithFormat(@"%@%@", [NSString stringWithFormat:@"%@/ntocc-tps-api",[ReAddressDynamic shared].baseUrl], FILE_UPLOAD);

        
        [HTTPManager postUploadFiles:uploadUrl file:imgArr fileName:@"file" withVC:self netName:@"文件上传" success:^(id response, NSString *msg) {
            NSMutableDictionary *dic = self.dataArr[_curentIndexPath.row];
            dic[@"imgURL"] = response[@"data"];
            [self OCRNetworking:response[@"data"]];
//            [self.tableView reloadSection:self.curentIndexPath.section withRowAnimation:(UITableViewRowAnimationNone)];
            
        } failure:^(NSInteger code, NSString *msg) {
            
        }];
        
    }];
    imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:imagePickerVc animated:YES completion:nil];
}

#pragma mark - Camera(检查相机权限方法)
- (void)checkCameraPermission {
    AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    if (status == AVAuthorizationStatusNotDetermined) {
        [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
            if (granted) {
                [self takePhoto];
            }
        }];
    } else if (status == AVAuthorizationStatusDenied || status == AVAuthorizationStatusRestricted) {
        
        [self alertAlbum];//如果没有权限给出提示
    } else {
        [self takePhoto];//有权限进入调起相机方法
    }
}
- (void)takePhoto {
#pragma mark - 07.判断相机是否可用，如果可用调起
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        self.imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
        dispatch_async(dispatch_get_main_queue(), ^{
            [self presentViewController:self.imagePickerController animated:YES completion:^{
                
            }];
        });
        
    } else {//不可用只能GG了
        NSLog(@"没有相机");
    }
}
#pragma mark - Album(相册流程与相机流程相同,相册是不存在硬件问题的,只要有权限就可以直接调用)
- (void)checkAlbumPermission {
    PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
    if (status == PHAuthorizationStatusNotDetermined) {
        [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
            dispatch_async(dispatch_get_main_queue(), ^{
                if (status == PHAuthorizationStatusAuthorized) {
                    [self selectAlbum];
                }
            });
        }];
    } else if (status == PHAuthorizationStatusDenied || status == PHAuthorizationStatusRestricted) {
        [self alertAlbum];
    } else {
        [self selectAlbum];
    }
}
- (void)selectAlbum {
    //判断相册是否可用
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        self.imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        [self presentViewController:self.imagePickerController animated:YES completion:^{
            
        }];
    }
}

- (void)alertAlbum {
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"请在设置中打开相册" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        [self dismissViewControllerAnimated:YES completion:nil];
    }];
    [alert addAction:cancel];
    [self presentViewController:alert animated:YES completion:nil];
}
#pragma mark - 03.懒加载初始化弹框;
- (UIImagePickerController *)imagePickerController {
    if (_imagePickerController == nil) {
        _imagePickerController = [[UIImagePickerController alloc] init];
        _imagePickerController.modalPresentationStyle = UIModalPresentationFullScreen;
        _imagePickerController.delegate = self; //delegate遵循了两个代理
        _imagePickerController.allowsEditing = YES;
        _imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    }
    return _imagePickerController;
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *)info{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    NSMutableArray *arr = [NSMutableArray array];
    [arr addObject:image];
    NSString *uploadUrl = CJStringWithFormat(@"%@%@", [NSString stringWithFormat:@"%@/ntocc-tps-api",[ReAddressDynamic shared].baseUrl], FILE_UPLOAD);

    [HTTPManager postUploadFiles:uploadUrl file:arr fileName:@"file" withVC:self netName:@"文件上传" success:^(id response, NSString *msg) {
        NSMutableDictionary *dic = self.dataArr[_curentIndexPath.row];
        dic[@"imgURL"] = response[@"data"];
        [self OCRNetworking:response[@"data"]];
        [self.imagePickerController dismissViewControllerAnimated:YES completion:^{
                    
                }];
//        [self.tableView reloadSection:self.curentIndexPath.section withRowAnimation:(UITableViewRowAnimationNone)];
    } failure:^(NSInteger code, NSString *msg) {
        
    }];
}
- (void)OCRNetworking:(NSString *)string{
    NSMutableDictionary *di = self.dataArr[self.curentIndexPath.row];
    NSDictionary *parmas;
    if ([di[@"title"] isEqualToString:@"机动车驾驶证"]) {
        parmas  = @{
            @"image": string,
            @"ocrType": @"6",
            @"token":[UserDefaultUtil valueForKey:USER_TOKEN],
        };
        di[@"upType"] = @"0";
        for (NSInteger i = self.dataArr.count - 1; i >= 0; i--) {
            NSDictionary *dic = self.dataArr[i];
            if ([dic[@"title"] isEqualToString:@"电子机动车驾驶证副页上传"]) {
                [self.dataArr removeObjectAtIndex:i];
            }
        }
        
    }else if([di[@"title"] isEqualToString:@"电子机动车驾驶证副页上传"]){
        parmas  = @{
            @"image": string,
            @"ocrType": @"13",
            @"token":[UserDefaultUtil valueForKey:USER_TOKEN],
        };
    }else if([di[@"title"] isEqualToString:@"道路运输从业资格证"]){
        parmas = @{
            @"image": string,
            @"ocrType": @"8",
            @"token":[UserDefaultUtil valueForKey:USER_TOKEN],
        };
        di[@"upType"] = @"0";
        for (NSInteger i = self.dataArr.count - 1; i >= 0; i--) {
            NSDictionary *dic = self.dataArr[i];
            if ([dic[@"title"] isEqualToString:@"道路运输从业资格证有效期最新页(没有就不上传)"]) {
                [self.dataArr removeObjectAtIndex:i];
            }
        }
    }else if([di[@"title"] isEqualToString:@"道路运输从业资格证有效期最新页(没有就不上传)"]){
        parmas = @{
            @"image": string,
            @"ocrType": @"8",
            @"token":[UserDefaultUtil valueForKey:USER_TOKEN],
        };
    }
    [HTTPManager jsonNetworkRequestWithMethod:@"POST" urlString:CJStringWithFormat(@"%@%@", [NSString stringWithFormat:@"%@/ntocc-tps-api",[ReAddressDynamic shared].baseUrl], NTOCC_OCRCARD) withParameter:parmas withVC:self netName:@"OCR识别" success:^(id response, NSString *msg) {
        [XSInfoView showInfo:msg onView:self.view];
        if ([di[@"title"] isEqualToString:@"机动车驾驶证"]) {
            [self.jszDic addEntriesFromDictionary:response];
            if ([DCSpeedy isBlankString:response[@"issuingAuthority"]] == YES) {
                if ([di[@"upType"] intValue] == 0) {
                    NSMutableDictionary *dic2 = [NSMutableDictionary dictionary];
                    [dic2 setValue:@"电子机动车驾驶证副页上传" forKey:@"title"];
                    [dic2 setValue:@"" forKey:@"imgURL"];
                    [dic2 setValue:@"0" forKey:@"upType"];//0没识别之前 1 成功。2 失败
                    [dic2 setValue:@"识别失败(点击重新上传)" forKey:@"falseTitle"];
                    [dic2 setValue:@"曝光严重无法准确识别文字内容" forKey:@"falseCentent"];
                    [dic2 setValue:@"dianzijiashizhengfuye" forKey:@"defaultImag"];
                    [dic2 setValue:@"dianzijiashizhengfuyeshilie" forKey:@"ballbackImag"];
                    for (int i = 0; i < self.dataArr.count; i++) {
                        NSDictionary *dic = self.dataArr[i];
                        if ([dic[@"title"] isEqualToString:@"机动车驾驶证"]) {
                            [self.dataArr insertObject:dic2 atIndex:i+1];
                            break;
                        }
                    }
                }
            }
           
        }else if ([di[@"title"] isEqualToString:@"电子机动车驾驶证副页上传"]) {
            [self.jszFyDic addEntriesFromDictionary:response];
        }else if ([di[@"title"] isEqualToString:@"道路运输从业资格证"]) {
            [self.cyzgzDic addEntriesFromDictionary:response];
            if ([di[@"upType"] intValue] == 0) {
                if ([response[@"道路运输从业资格证是否过期"] boolValue] == YES) {
                    self.daoluUpTimeBool = NO;
                    NSMutableDictionary *dic2 = [NSMutableDictionary dictionary];
                    [dic2 setValue:@"道路运输从业资格证有效期最新页(没有就不上传)" forKey:@"title"];
                    [dic2 setValue:@"" forKey:@"imgURL"];
                    [dic2 setValue:@"0" forKey:@"upType"];//0没识别之前 1 成功。2 失败
                    [dic2 setValue:@"识别失败(点击重新上传)" forKey:@"falseTitle"];
                    [dic2 setValue:@"曝光严重无法准确识别文字内容" forKey:@"falseCentent"];
                    [dic2 setValue:@"daolucongyezigezhengnew" forKey:@"defaultImag"];
                    [dic2 setValue:@"congyezigezhengshijianshilie" forKey:@"ballbackImag"];
                    [self.dataArr addObject:dic2];
                }else{
                    self.daoluUpTimeBool = YES;
                }
            }
        }else if ([di[@"title"] isEqualToString:@"道路运输从业资格证有效期最新页(没有就不上传)"]) {
            [self.cyzgzDicTime addEntriesFromDictionary:response];
            if ([response[@"道路运输从业资格证是否过期"] boolValue] == YES) {//不过期就隐藏提示
                self.daoluUpTimeBool = NO;
            }else{
                self.daoluUpTimeBool = YES;
            }
        }
        di[@"upType"] = @"1";
        di[@"falseTitle"] = @"";
        di[@"falseCentent"] = @"";
        [self.tableView reloadData];
    } failure:^(NSInteger code, NSString *msg) {
        NSMutableDictionary *dicD = self.dataArr[_curentIndexPath.row];
        dicD[@"upType"] = @"2";
        dicD[@"falseTitle"] = @"识别失败(点击重新上传)";
        dicD[@"falseCentent"] = msg;
        [self.tableView reloadData];
    }];

}
- (NSString *)dicZhuanJsonStr:(NSDictionary *)dic{
    NSError *error;
    if (dic) {
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:0 error:&error];
        if (!jsonData) {
            NSLog(@"Error converting DiC%@",error);
            return @"";
        }else{
            return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        }
    }else{
        return @"";
    }
    
}
- (void)setupNav {
    UIImage *bgImage = [[UIImage imageWithColor:UIColor.whiteColor] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch];
    [DCSpeedy changeNavControllerGradientView:self andBgColor:bgImage andTitleColor:[UIColor blackColor]];
    UIButton *button = [[UIButton alloc] init];
    [button setImage:[UIImage imageNamed:@"gcy_img_nav_lArrow"] forState:UIControlStateNormal];
    button.frame = CGRectMake(0, 0, 17, 32);
    [button addTarget:self action:@selector(backButtonTapClick) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem = backItem;
}

- (void)backButtonTapClick {
    if ([self.sussType isEqualToString:@"0"]) {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
   
}
@end
